package com.fjl.boot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.core.env.ConfigurableEnvironment;

import java.util.HashMap;
import java.util.Map;

// 2. EnvironmentPostProcessor: 启动环境修改
 class MyEnvironmentPostProcessor implements EnvironmentPostProcessor {
    @Override
    public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
        System.out.println(">> EnvironmentPostProcessor");
        Map<String, Object> props = new HashMap<>();
        props.put("my.custom.property", "helloFromEnvPostProcessor");
        environment.getPropertySources().addFirst(new org.springframework.core.env.MapPropertySource("myProps", props));
    }
}